package example.com.nexd.collectionsdk.sdk.collector;

import android.content.Context;
import android.content.pm.PackageManager;
import android.hardware.SensorManager;

/**
 * WifiCollector create by codingfish at 15/4/29
 * TODO:
 *
 * @Version V1.0
 */
public abstract class Collector implements ICollector {

    protected String TAG = Collector.class.getSimpleName();
    protected Context context;
    protected CollectorConfig collectorConfig;
    /*打开采集设备的方式：手动*/
    public static final int bluetooth_enable_mode_manual =10010;
    /*打开采集设备的方式：自动*/
    public static final int bluetooth_enable_mode_auto =10011;
    /*采集模式：主动采集*/
    public static final int COLLECTION_MODE_ACTIVE = 0;
    /*采集模式：被动采集*/
    public static final int COLLECTION_MODE_PASSIVE = 1;
    /*Sensor 采集速率：默认*/
    public static final int COLLEction_sensor_DELAY_NORMAL = SensorManager.SENSOR_DELAY_NORMAL;
    /*Sensor 采集速率：UI*/
    public static final int COLLEction_sensor_DELAY_UI = SensorManager.SENSOR_DELAY_UI;
    /*Sensor 采集速率：GAME*/
    public static final int COLLEction_sensor_DELAY_GAME = SensorManager.SENSOR_DELAY_GAME;
    /*Sensor 采集速率：FASTEST*/
    public static final int COLLEction_sensor_DELAY_FASTEST = SensorManager.SENSOR_DELAY_FASTEST;
    /*没有相应的权限*/
    public static final int FAIED_ID_NO_PERMISSION = 0;
    /*扫描结果为 null*/
    public static final int FAIED_ID_RESULT_NULL = 1;
    /*采集器不可用*/
    public static final int FAIED_ID_COLLECTOR_STATE_OFF = 2;
    /*失败：Context 对象为空*/
    public static final int FAILED_ID_CONTEXT_NULL = 3;
    /*失败，不支持的传感器类型*/
    public static final int FAILED_ID_UNSUPPORTED_SENSOR_TYPE = 4;
    public static final int FAILED_ID_MANAGER_INIT_FAILED = 5;
    /*失败，蓝牙设备不能扫描*/
    public static final int FAILED_ID_SCAN_MODE_NONE = 6;

    protected Collector(Context context, CollectorConfig collectorConfig) {
        this.context = context;
        this.collectorConfig = collectorConfig;
    }

    public boolean checkPermission(String permission) {
        int res = context.checkCallingOrSelfPermission(permission);
        return (res == PackageManager.PERMISSION_GRANTED);
    }

}
